package com.itheima.controller.backend.reservation;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.common.vo.ReportBusinessVo;
import com.itheima.common.vo.ReportMemberVo;
import com.itheima.common.vo.ReportSetMealVo;
import com.itheima.service.ReportService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @className ReportController
 */
@RestController
@RequestMapping("/report")
@RequiredArgsConstructor
public class ReportController {

    private final ReportService reportService;

    /**
     * 会员数量统计报表
     * @return
     */
    @GetMapping("/getMemberReport")
    public Result getMemberReport(){
        ReportMemberVo reportMemberVo = reportService.getMemberReport();
        return new Result(true, MessageConstant.GET_MEMBER_NUMBER_REPORT_SUCCESS,reportMemberVo);
    }

    /**
     * 套餐占比统计报表
     * @return
     */
    @GetMapping("/getSetmealReport")
    public Result getSetMealReport(){
        ReportSetMealVo reportSetMealVo = reportService.getSetMealReport();
        return new Result(true, MessageConstant.GET_SETMEAL_COUNT_REPORT_SUCCESS,reportSetMealVo);
    }

    /**
     * 运营数据统计报表
     * @return
     */
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData(){
        ReportBusinessVo reportBusinessVo = reportService.getBusinessReportData();
        return new Result(true, MessageConstant.GET_BUSINESS_REPORT_SUCCESS,reportBusinessVo);
    }

    /**
     * 导出Excel运营数据统计报表
     * @return
     */
    // @GetMapping("/exportBusinessReport")
    public Result exportBusinessReportByExcel(){

        //TODO 有bug，fastExcel导出数据为空

        ReportBusinessVo reportBusinessVo = reportService.getBusinessReportData();
        String path = reportService.exportBusinessReportByExcel(reportBusinessVo);
        return new Result(true, MessageConstant.BUSINESS_REPORT_EXCEL_SUCCESS,path);
    }

}
